#include "yamlConfig.h"

bool yamlHandler::_init_(std::string fileName)
{
    //读取相机配置文件
    config = YAML::LoadFile(fileName);
    
    const YAML::Node& _resolution = config[0]["resolution"];
    fps = config[0]["fps"].as<float>();
    pixelFormat = config[0]["pixelFormat"].as<float>();
    resolution[0] = _resolution[0].as<float>();
    resolution[1] = _resolution[1].as<float>();
    width = resolution[0];
    height = resolution[1];
    std::cout << "fps:          " << fps << "\n"
              << "pixelFormat:  " <<  pixelFormat << "\n"
              << "resolution:   (" << resolution[0] << "," << resolution[1] <<")"
              << std::endl;
    return true;
}

int yamlHandler::getDeviceId(DEVICEID ID)
{
    int enumId = ID, id;
    YAML::Node deviceYamlConfig = config[enumId]["deviceinfo"];
    id = deviceYamlConfig["Id"].as<int>();
    return id;
}